package exhi.action;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import exhi.entity.ExhiCfg;

@Controller
@RequestMapping("/comm")
public class CommCfgAct extends BaseAct {

	private static final String PATH_CFG_EXHI_DETAIL = "/exhi-cfg-detail";
	private static final String PATH_CFG_EXHI_SAVE = "/exhi-cfg-save";

	// 详细信息
	@RequestMapping(PATH_CFG_EXHI_DETAIL)
	public void exhiCfg(
			@RequestParam(required = true, defaultValue = "") String code,
			ModelMap model) {
		ExhiCfg cfg = stdInitMng.getInitObj("exhiCfg", ExhiCfg.class);
		if (cfg == null)
			cfg = new ExhiCfg();
		model.addAttribute("cfg", cfg);
	}

	// 保存
	@RequestMapping(PATH_CFG_EXHI_SAVE)
	public void ExhiCfgSave(@ModelAttribute("exhiCfg") ExhiCfg cfg, ModelMap model) {
		if (null != cfg)
			stdInitMng.addInitObj("exhiCfg", cfg);
	}

	@ModelAttribute("exhiCfg")
	public ExhiCfg getExhiCfg() {
		ExhiCfg cfg = stdInitMng.getInitObj("exhiCfg",  ExhiCfg.class);
		if (cfg == null)
			cfg = new ExhiCfg();
		return cfg;
	}


}
